﻿/**
 *	\file		lolix_type.h
 *	\date		(2007-03-06 20:55:33)/(2015-01-09 00:33:13)
 *-----------------------------------------------------------------------------
 *	\brief		lolix 使用的简单的类型定义.
 *	\version	1.0.62.100
 *	\author		Nick Shallery	(nicknide@gmail.com)
 *	\copyright	YOU HAVE ALL LEFT WITH THIS CODE WHILE YOU KEEP COMMENT IN EVERY COPY.
 *-----------------------------------------------------------------------------
**/

#if			!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
#define		__LOLIX__LOLIX_TYPE__K_IN_G__
//==============================================================================
//--------------------------------------------------------------------------
#if			!defined(__LOLIX__LOLI_X_CFG__K_IN_G__)
	#include	"./lolix_cfg.h"
#endif	//	!defined(__LOLIX__LOLI_X_CFG__K_IN_G__)

#if			!defined(__LOLIX__LOLIX_ERR__K_IN_G__)
	#include	"./lolix_err.h"
#endif	//	!defined(__LOLIX__LOLIX_ERR__K_IN_G__)

#if			!defined(__LOLIX__LOLI_X_MACRO__K_IN_G__)
	#include	"./lolix_macro.h"
#endif	//	!defined(__LOLIX__LOLI_X_MACRO__K_IN_G__)

#if			!defined(__LOLIX__LOLIX_SUPPORTED__HPP__K_IN_G__)
	#include	"./_lolix_supported.hpp"
#endif	//	!defined(__LOLIX__LOLIX_SUPPORTED__HPP__K_IN_G__)

#if			LOLIX_CFG__USE_LOCK_OPT_REF_COUNTER && !defined(__LOLIX_IMP__LOLIX_LOCK_OPT__H__NICK__K_IN_G__)
	#include	"./imp/lolix_lock_opt.h"
#endif	//	LOLIX_CFG__USE_LOCK_OPT_REF_COUNTER && !defined(__LOLIX_IMP__LOLIX_LOCK_OPT__H__NICK__K_IN_G__)


namespace lolix{
	enum LOLIX_RETNV;

#if			LOLIX_CFG__SIZE_TYPE_BITS_SIZE == 64
	typedef unsigned long long size_type;
	typedef long long difference_type;
#elif		LOLIX_CFG__SIZE_TYPE_BITS_SIZE == 32
	typedef unsigned int size_type;
	typedef int difference_type;
#else	//	LOLIX_CFG__SIZE_TYPE_BITS_SIZE == ??
	#error Unsupport bits size.
#endif	//	LOLIX_CFG__SIZE_TYPE_BITS_SIZE == ??

	//typedef	toy::size_info<size_t(~0)>::size_type		size_type;
	//typedef	toy::size_info<size_t(~0)>::difference_type	difference_type;
	typedef	difference_type	ptrdiff_type;
#if         defined(_MSC_VER)
#define	__LOLIX_TMP_DEFINE__DEF_TYPE__(bits_cnt)	typedef	signed	__int##bits_cnt lx_i##bits_cnt;\
													typedef	unsigned __int##bits_cnt	lx_u##bits_cnt
	__LOLIX_TMP_DEFINE__DEF_TYPE__(8);	//	lx_i8, lx_u8
	__LOLIX_TMP_DEFINE__DEF_TYPE__(16);	//	lx_i16, lx_u16
	__LOLIX_TMP_DEFINE__DEF_TYPE__(32);	//	lx_i32, lx_u32
	__LOLIX_TMP_DEFINE__DEF_TYPE__(64);	//	lx_i64, lx_u64
	typedef char		lx_char;
	typedef __wchar_t	lx_wchar;
#undef	__LOLIX_TMP_DEFINE__DEF_TYPE__
#else   //  defined(_MSC_VER)
	typedef signed char lx_i8;
	typedef unsigned char   lx_u8;
	typedef signed short lx_i16;
	typedef unsigned short lx_u16;
	typedef signed int lx_i32;
	typedef unsigned int lx_u32;
	typedef signed long long lx_i64;
	typedef unsigned long long lx_u64;

	typedef char	lx_char;
	typedef wchar_t	lx_wchar;

#endif  //  defined(_MSC_VER)

#if			defined(LOLIX_DEF__PLATFORM_TYPE_WINDOWS)
	typedef lx_wchar	lx_pchar;	//	path char
#else	//	defined(LOLIX_DEF__PLATFORM_TYPE_WINDOWS)
	typedef lx_char		lx_pchar;	//	path char
#endif	//	defined(LOLIX_DEF__PLATFORM_TYPE_WINDOWS)

	typedef	float	lx_f32;
	typedef	double	lx_f64;

	#define	LOLIX_ABS(x)	::lolix::toy::abs(x)

	class	type_true	{public: enum {value = 1}; struct value_size{char __dat[4];}size_value;};
	class	type_false	{public: enum {value = 0}; struct value_size{char __dat[1];}size_value;};
	STATIC_ASSERT(sizeof(type_true::value_size) != sizeof(type_false::value_size));
	STATIC_ASSERT(type_true::value != type_false::value);

	/**
	* \brief	接口的类型ID
	**/
	struct LOLIX_ITF_ID{
		///	接口类型的4个32位值，累计为128GUID
		lx_u32	r, g, b, a;
		/**
		* \brief	判断当前ID是否和目标ID相等
		* \arg	o	待判断的ID
		* \return	相等则返回true;否则返回false
		**/
		LOLIX_INLINE_CALL bool operator == (const LOLIX_ITF_ID& o)const
			{
			return r == o.r && g == o.g && b == o.b && a == o.a;
			}
		/**
		* \brief	判断当前ID是否和目标ID不等
		* \arg	o	待判断的ID
		* \return	不等则返回true;否则返回false
		**/
		LOLIX_INLINE_CALL bool operator != (const LOLIX_ITF_ID& o)const
			{
			return !((*this) == o);
			}

		/**
		* \brief	从源ID复制ID
		* \arg	o	源ID
		* \return	返回自身的引用
		**/
		LOLIX_INLINE_CALL LOLIX_ITF_ID& operator = (const LOLIX_ITF_ID& o)
			{
			r = o.r; g = o.g; b = o.b; a = o.a;
			return *this;
			}
		/**
		* \brief	用四个ID值初始化自身
		* \arg	ir	第一个分量
		* \arg	ig	第二个分量
		* \arg	ib	第三个分量
		* \arg	ia	第四个分量
		**/
		LOLIX_INLINE_CALL LOLIX_ITF_ID(lx_u32 ir, lx_u32 ig, lx_u32 ib, lx_u32 ia)
			: r(ir), g(ig), b(ib), a(ia)
			{
			}
		/**
		* \brief	用另一个ID类型
		* \arg	o	另一个ID类型
		**/
		LOLIX_INLINE_CALL LOLIX_ITF_ID(const LOLIX_ITF_ID& o)
			: r(o.r), g(o.g), b(o.b), a(o.a)
			{
			}
		/**
		* \brief	默认构造
		**/
		LOLIX_INLINE_CALL LOLIX_ITF_ID(void)
			{
			}

		/**
		* \brief	根据一个接口获得接口ID对象
		* \tparam	_Ty	待处理类型
		* \arg		tp	待处理对象的指针(用于类型推导)
		* \return	返回_Ty类型的ID
		**/
		template<typename _Ty>
		static	LOLIX_INLINE_CALL	const LOLIX_ITF_ID	__get_by_type_ptr(_Ty* tp)
			{
			return LOLIX_ITF_ID((lx_u32)_Ty::_lx_itf_id_r, (lx_u32)_Ty::_lx_itf_id_g, (lx_u32)_Ty::_lx_itf_id_b, (lx_u32)_Ty::_lx_itf_id_a);
			}

		struct	compare_type;
	};	//	lolix type id

	/**
	* \brief	用于比较接口ID对象的辅助接口
	**/
	struct	LOLIX_ITF_ID::compare_type
	{
		/**
		* \brief	比较两个接口ID对象
		* \arg	l	第一个接口对象ID
		* \arg	r	第二个接口对象ID
		* \return	如果想等，则返回true， 否则返回false
		**/
		LOLIX_INLINE_CALL	bool operator ()(const LOLIX_ITF_ID& l, const LOLIX_ITF_ID& r)const
		{
#define		LOLIX_TMP_OPERATOR_CMP(v)	if ( l.v < r.v ) return true;if ( l.v > r.v ) return false
			LOLIX_TMP_OPERATOR_CMP(r);
			LOLIX_TMP_OPERATOR_CMP(g);
			LOLIX_TMP_OPERATOR_CMP(b);
			LOLIX_TMP_OPERATOR_CMP(a);
#undef		LOLIX_TMP_OPERATOR_CMP
			return false;
		}
	};

#if			LOLIX_CFG__USE_CLASS_ALLOC
	#define	LOLIX_DEF__OWNER_CLASS_ALLOC(self_name)	LOLIX_ALLOC(#self_name, _T_ITF_ALC);typedef _T_ITF_ALC<self_name> allocator_type

#else	//	LOLIX_CFG__USE_CLASS_ALLOC
	#define	LOLIX_DEF__OWNER_CLASS_ALLOC(self_name)	typedef lolix::toy::itf_alc::_T_ITF_ALC<self_name>	allocator_type

#endif	//	LOLIX_CFG__USE_CLASS_ALLOC

	#define	LOLIX_DECLARE_ITF(self_name, base_name, id)		\
		private:\
			typedef	self_name this_type;\
			typedef base_name base_type;\
			friend	::lolix::_help::__query_itf;\
		public:\
			LOLIX_DEFINE_ITF_ID id

	#define	LOLIX_DEFINE_ITF_WITH_ALC(self_name, base_name, id, get_alc)	\
		friend ::lolix::itf_Tbase<self_name, base_name>;\
		friend	::lolix::_help::__query_itf;\
	public:\
		using base_name::query_itf;\
		using base_name::inc_ref;\
		using base_name::release;\
		using base_name::itf_id;\
		virtual	::lolix::LOLIX_RETNV	LOLIX_CALL	query_itf(itf** out_ptr, ::lolix::LOLIX_ITF_ID const* in_id)\
		{return ::lolix::_help::__query_itf::do_query<this_type>(this, out_ptr, in_id);}\
		LOLIX_DEFINE_ITF_WITH_ALC_WITHOUT_QUERY(self_name, base_name, id, get_alc)

#if			LOLIX_CFG__USE_LOCK_OPT_REF_COUNTER
	#define	__LOLIX_DEFINE__REF_COUNTER_TYPE()	typedef ::lolix::_help::_TRefHandle<::lolix::size_type, ::lolix::type::type_inherit<::lolix::itf_Tbase<this_type, base_type>, this_type>::value> ref_type
#else	//	LOLIX_CFG__USE_LOCK_OPT_REF_COUNTER
	#define	__LOLIX_DEFINE__REF_COUNTER_TYPE()	::lolix::ref_counter*	ref_type
#endif	//	LOLIX_CFG__USE_LOCK_OPT_REF_COUNTER

	#define	LOLIX_DEFINE_ITF_WITH_ALC_WITHOUT_QUERY(self_name, base_name, id, get_alc)	\
private:\
	LOLIX_DECLARE_ITF(self_name, base_name, id);\
	LOLIX_INLINE_CALL void __lolix_inner_delete_this(::lolix::dynamic_allocator* alc)const{\
		allocator_type alc_this(alc);\
		this_type* const p = const_cast<this_type*>(this);\
		alc_this.destroy(p);\
		alc_this.deallocate(p, 1);\
	}\
	virtual	::lolix::size_type LOLIX_CALL inc_ref(void)const{return ::lolix::_help::__query_itf::do_inc_ref(this);}\
	virtual ::lolix::size_type LOLIX_CALL release(void)const{return ::lolix::_help::__query_itf::do_release(this, get_alc);}\
	virtual	void LOLIX_CALL	itf_id(::lolix::LOLIX_ITF_ID* out_id)const{LOLIX_ITF_ID_FROM(out_id, this_type);}\
	LOLIX_DEF__OWNER_CLASS_ALLOC(self_name);\
	friend	allocator_type;\
	__LOLIX_DEFINE__REF_COUNTER_TYPE();\
	ref_type _ref;\
	LOLIX_DEF__CANNT_COPY_LOLI

	#define		LOLIX_DEF__DECLTYPE(val)				::lolix::remove_reference<decltype(val)>::type
	#define		LOLIX_DEFINE_ITF(self_name, base_name, id)	LOLIX_DEFINE_ITF_WITH_ALC(self_name, base_name, id, _alc)
	#define		LOLIX_DEFINE_ITF_ID(r, g, b, a)			enum _lx_itf_id{ _lx_itf_id_r = (r), _lx_itf_id_g = (g), _lx_itf_id_b = (b), _lx_itf_id_a = (a) }
	#define		LOLIX_ITF_ID_FROM(id_ptr, type)			__LOLIX__BEGIN_MACRO() (id_ptr)->r = (::lolix::lx_u32)type::_lx_itf_id_r; (id_ptr)->g = (::lolix::lx_u32)type::_lx_itf_id_g, (id_ptr)->b = (::lolix::lx_u32)type::_lx_itf_id_b, (id_ptr)->a = (::lolix::lx_u32)type::_lx_itf_id_a; __LOLIX__END_MACRO()
	#define		LOLIX_ITF_FROM_TYPE(type)				::lolix::LOLIX_ITF_ID::__get_by_type_ptr<type>(0)
	#define		LOLIX_ITF_FROM_VAL(val)					LOLIX_ITF_FROM_TYPE(LOLIX_DEF__DECLTYPE(val))
	#define		LOLIX_ITF_ID_EQUL_WITH_TYPE(id, type)	( (id)->r == type::_lx_itf_id_r && (id)->g == type::_lx_itf_id_g && (id)->b == type::_lx_itf_id_b && (id)->a == type::_lx_itf_id_a )
	#define	LOLIX_DEFINE_GLOBAL_ITF(self_name, base_name, id)	\
		public:\
			using base_name::query_itf;\
			using base_name::inc_ref;\
			using base_name::release;\
			using base_name::itf_id;\
			virtual	::lolix::LOLIX_RETNV	LOLIX_CALL	query_itf(itf** out_ptr, ::lolix::LOLIX_ITF_ID const* in_id)\
			{return ::lolix::_help::__query_itf::do_query<this_type>(this, out_ptr, in_id);}\
		private:\
			LOLIX_DECLARE_ITF(self_name, base_name, id);\
			LOLIX_INTERFACE_DEFINE(inc_ref, size_type, (void)const){return 2;}\
			LOLIX_INTERFACE_DEFINE(release, size_type, (void)const){return 0;}\
			LOLIX_INTERFACE_DEFINE(itf_id	, void	, (::lolix::LOLIX_ITF_ID* out_id)const){LOLIX_ITF_ID_FROM(out_id, this_type);}\
			LOLIX_DEF__CANNT_COPY_LOLI


	namespace type{
		#pragma	region	//	u_type define
		/**
		* \brief	联合体对象
		* \tparam	_Tl	第一个对象类型
		* \tparam	_Tr	第二个对象类型
		**/
		template<typename _Tl, typename _Tr>
		union u_type
		{
		private:
			template<typename gcc_only, bool>
			struct cp
			{
				static LOLIX_INLINE_CALL void copy(u_type<_Tl, _Tr>& s, u_type<_Tl, _Tr> o){ s.first = o.first; }
			};
			template <typename gcc_only>
			struct cp<gcc_only, false>
			{
				static LOLIX_INLINE_CALL void copy(u_type<_Tl, _Tr>& s, u_type<_Tl, _Tr> o){ s.second = o.second; }
			};
		public:
			typedef _Tl	first_type;	///< \brief	第一个对象类型
			typedef	_Tr	second_type;///< \brief	第二个对象类型

			/**
			* \brief	使用第一类型初始化对象
			*
			* \arg	lt	初始化的源
			**/
			LOLIX_INLINE_CALL explicit u_type(const _Tl& lt):first(lt){}

			/**
			* \brief	使用第二类型初始化对象
			*
			* \arg	rt	初始化的源
			**/
			LOLIX_INLINE_CALL explicit u_type(const _Tr& rt):second(rt){}

			/**
			* \brief	默认构造
			**/
			LOLIX_INLINE_CALL u_type(void){}

			/**
			* \brief	从对等对象中赋值
			*
			* \arg	o	源对象
			**/
			LOLIX_INLINE_CALL u_type<_Tl,_Tr> operator = (u_type<_Tl,_Tr> o){ cp<void, (sizeof first >sizeof second)>::copy(*this, o); return *this;}

			union
			{
			first_type	first;	/// \brief	第一类型对象
			second_type	second;	/// \brief	第二类型对象
			};
		};

		/**
		* \brief	两个类型相同的联合体对象
		* \tparam	制定的联合体类型
		* \remark	这个对象是为了防止因为模板等类型推导导致了相同类型而出现歧义特化的
		**/
		template<typename _Ty>
		union u_type<_Ty, _Ty>
		{
		public:
			typedef _Ty	first_type; ///< \brief 联合类型
			typedef _Ty	second_type;///< \brief	联合类型

			/**
			* \brief	根据源对象进行初始化
			* \arg	lt	源对象数据
			**/
			LOLIX_INLINE_CALL explicit u_type(_Ty lt):first(lt){}

			/**
			* \brief	按照默认方式初始化对象
			**/
			LOLIX_INLINE_CALL u_type(void){}
			/**
			* \brief	从源对象复制数据
			* \arg	o	源对象
			**/
			LOLIX_INLINE_CALL u_type<_Ty,_Ty> operator = (u_type<_Ty,_Ty> o){ first = o.first; return *this;}
			union
			{
				_Ty	first; ///< \brief 第一类型对象
				_Ty	second;///<	\brief 第二类型对象
			};
		};
		#pragma	endregion
		#pragma region	//	type_choise	define
		/**
		* \brief	根据值选择不同的类型
		* \tparam	is_true	是否是真
		* \tparam	L	如果is_true == true, 则选定此类型作为候选类型
		* \tparam	R	如果is_true == false, 则选定此类型作为候选类型
		**/
		template<bool is_true, typename L, typename R>
		struct type_choise
		{
			typedef L type;///<	当选择之为真，则将第一类型返回s
		};

		/**
		* \brief	根据值选择不同的类型(此特化直接选取第二类型)
		* \tparam	L	如果is_true == true, 则选定此类型作为候选类型
		* \tparam	R	如果is_true == false, 则选定此类型作为候选类型
		**/
		template<typename L, typename R>
		struct type_choise<false, L, R>
		{
			typedef R type;///<	使用第二类型作为返回类型
		};

		/**
		* \brief	将类型信息转化为0或者1
		* \tparam V	需要转化的类型
		**/
		template<typename V> class cast_type_to_bool;
		/**
		* \brief	将type_true转化为1
		**/
		template<> class cast_type_to_bool<type_true>{public:enum {value = 1/**值*/};};
		/**
		* \brief	将type_true转化为1
		**/
		template<> class cast_type_to_bool<type_false>{public:enum {value = 0/**值*/};};
		#pragma endregion
		#pragma region	//	type_equal define
		template<typename L, typename R>
		class type_equal
		{
		public:
			enum {value = 0};
		};

		template<typename T>
		class type_equal<T, T>
		{
		public:
			enum {value = 1};
		};
		#pragma endregion

		#pragma region	//	type_inherit define
		template<typename B, typename D>
		class type_inherit
		{
			static type_true::value_size __check_inherit(B*);
			static type_false::value_size __check_inherit(...);
		public:
			enum {is_equal = type_equal<B, D>::value};
			enum { value = is_equal
				? false
				: (sizeof(__check_inherit(static_cast<D*>(0))) == sizeof (type_true::value_size))
			};
		};
		#pragma endregion

		///	\brief 定义类型的一些常用扩展类型
		/// \tparam	_T	原始的类型
		template<typename _T>struct type_def
			{
			typedef typename remove_const<typename remove_reference<_T>::type>::type value_type;///< \brief	值类型
			typedef const value_type const_value_type;	///< \brief	常量值类型
			typedef value_type& reference;				///< \brief	引用类型
			typedef const value_type& const_reference;	///< \brief	常量引用类型
			typedef value_type*	pointer;				///< \brief	指针类型
			typedef value_type*	const_pointer;			///< \brief	常量指针类型
			};
	}

	using type::u_type;
	class itf;
	namespace _help
	{
		struct	__query_itf
		{
#if			LOLIX_CFG__SUPPORT_CPP_0X
			template<typename>
			struct __get_mem_proc_owner;	//	得到成员函数指针的所有者
			#define	__LOLIX_DEF__PROC_TYPE(__CALL_TYPE, __PARAM, __HAVE_CONST, __IS_CONST)	template<typename _TRet, typename _TOwner>struct __get_mem_proc_owner<_TRet (__CALL_TYPE _TOwner::*) __PARAM __HAVE_CONST>{typedef _TRet ret_type;typedef _TOwner owner_type;enum{is_const = __IS_CONST};}
			#define	__LOLIX_DEF__PROC(__CALL_TYPE, __HAVE_CONST, __IS_CONST)	__LOLIX_DEF__PROC_TYPE(__CALL_TYPE, (itf** out_ptr, const LOLIX_ITF_ID* in_id), __HAVE_CONST, __IS_CONST)
#else	//	LOLIX_CFG__SUPPORT_CPP_0X
			#define	__LOLIX_DEF__PROC(__CALL_TYPE, __HAVE_CONST, __IS_CONST)	template<typename _TOwner, LOLIX_RETNV (_TOwner::*)(itf** out_ptr, const LOLIX_ITF_ID* in_id)>struct __get_mem_proc_owner{typedef LOLIX_RETNV ret_type;typedef _TOwner owner_type;enum{is_const = __IS_CONST};}
#endif	//	LOLIX_CFG__SUPPORT_CPP_0X

#if			LOLIX_CFG__SIZE_TYPE_BITS_SIZE < 64
			__LOLIX_DEF__PROC(__thiscall, , 0);
			__LOLIX_DEF__PROC(__stdcall, , 0);
			__LOLIX_DEF__PROC(__cdecl, , 0);
			#if			!defined(_M_CEE)
			__LOLIX_DEF__PROC(__fastcall, , 0);
			#endif	//	!defined(_M_CEE)
			__LOLIX_DEF__PROC(__thiscall, const, 1);
			__LOLIX_DEF__PROC(__stdcall, const, 1);
			__LOLIX_DEF__PROC(__cdecl, const, 1);
			#if			!defined(_M_CEE)
			__LOLIX_DEF__PROC(__fastcall, const, 1);
			#endif	//	!defined(_M_CEE)

#else	//	LOLIX_CFG__SIZE_TYPE_BITS_SIZE < 64
			__LOLIX_DEF__PROC(, , 0);
			__LOLIX_DEF__PROC(, const, 1);
#endif	//	LOLIX_CFG__SIZE_TYPE_BITS_SIZE < 64

			#undef	__LOLIX_DEF__PROC
			#undef	__LOLIX_DEF__PROC_TYPE

			template<typename _TDst, typename _Tsrc>
			struct __cast_type
			{
				static LOLIX_INLINE_CALL _TDst* cast_to_type(_Tsrc* ptr)
				{
					return __cast_type<_TDst, typename _Tsrc::base_type>::cast_to_type(ptr);
				}

				static LOLIX_INLINE_CALL _TDst* cast_from_type(_Tsrc* ptr)
				{
					_TDst::base_type* dptr = __cast_type<typename _TDst::base_type, _Tsrc>::cast_from_type(ptr);
					return static_cast<_TDst*>(dptr);
				}
			};

			template<typename _Tsrc>
			struct __cast_type<_Tsrc, _Tsrc>
			{
				static LOLIX_INLINE_CALL _Tsrc* cast_to_type(_Tsrc* ptr)
				{
					return ptr;
				}
				static LOLIX_INLINE_CALL _Tsrc* cast_from_type(_Tsrc* ptr)
				{
					return ptr;
				}
			};

			template<typename _TDst, typename _Tsrc>
			static LOLIX_INLINE_CALL _TDst __do_cast_to(_Tsrc* ptr)
			{
				return __cast_type<typedef remove_pointer<_TDst>::type, _Tsrc>::cast_to_type(ptr);
			}

			template<typename _TDst, typename _Tsrc>
			static LOLIX_INLINE_CALL _TDst __do_cast_from(_Tsrc* ptr)
			{
				return __cast_type<typedef remove_pointer<_TDst>::type, _Tsrc>::cast_from_type(ptr);
			}

#if			LOLIX_CFG__SUPPORT_CPP_0X
			template<typename _Tbase, typename _Ty>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query_call(_Ty* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, _Ty*)
			{
				LOLIX_RETNV rtv;
				if ( !LOLIX_IS_ERROR(rtv = ptr->__self_query_itf(out_ptr, in_id)) )
					return rtv;
				if ( !LOLIX_ITF_ID_EQUL_WITH_TYPE(in_id, _Ty) )
					return do_query<_Tbase>(__do_cast_to<typename _Ty::base_type*>(ptr), out_ptr, in_id);
				(*out_ptr = __do_cast_to<itf*>(ptr))->inc_ref();
				return LOLIX_RETNV_OK;
			}

			template<typename _Tbase, typename _Ty, typename _Towner>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query_call(_Ty* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, _Towner*)
			{
				if ( !LOLIX_ITF_ID_EQUL_WITH_TYPE(in_id, _Ty) )
					return do_query<_Tbase>((typename _Ty::base_type*)ptr, out_ptr, in_id);
				(*out_ptr = ptr)->inc_ref();
				return LOLIX_RETNV_OK;
			}

			template<typename _Tbase, typename _Ty>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query(_Ty* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, decltype(ptr->__self_query_itf) = 0)
			{
				return __do_query_call<_Tbase>(ptr, out_ptr, in_id, (typename __get_mem_proc_owner<decltype(&_Ty::__self_query_itf)>::owner_type*)0);
			}
#else	//	LOLIX_CFG__SUPPORT_CPP_0X
			template<typename _Tbase, typename _Ty>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query(_Ty* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, __get_mem_proc_owner<_Ty, LOLIX_RETNV (_Ty::*__self_query_itf)()>= 0)
			{
				LOLIX_RETNV rtv;
				if ( !LOLIX_IS_ERROR(rtv = ptr->__self_query_itf(out_ptr, in_id)) )
					return rtv;
				if ( !LOLIX_ITF_ID_EQUL_WITH_TYPE(in_id, _Ty) )
					return do_query<_Tbase>((_Ty::base_type*)ptr, out_ptr, in_id);
				(*out_ptr = ptr)->inc_ref();
				return LOLIX_RETNV_OK;
			}
#endif	//	LOLIX_CFG__SUPPORT_CPP_0X

			template<typename _Tbase, typename _Ty>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query(_Ty* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, ...)
			{
				if ( !LOLIX_ITF_ID_EQUL_WITH_TYPE(in_id, _Ty) )
					return do_query<_Tbase>((typename _Ty::base_type*)ptr, out_ptr, in_id);
				(*out_ptr = ptr)->inc_ref();
				return LOLIX_RETNV_OK;
			}

			template<typename _Tbase, typename _Ty>
			static LOLIX_INLINE_CALL LOLIX_RETNV do_query(_Ty* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id)
			{
				return __do_query<_Tbase>(ptr, out_ptr, in_id, 0);
			}

#if			LOLIX_CFG__SUPPORT_CPP_0X
			template<typename _Tbase>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query_when_last_error_call(_Tbase* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, _Tbase*)
			{
				LOLIX_RETNV rtv;
				if ( !LOLIX_IS_ERROR(rtv = __do_query_when_last_error(static_cast<typename _Tbase::base_type*>(ptr), out_ptr, in_id)) )
					return rtv;
				return ptr->__self_query_itf_end(out_ptr, in_id);
			}
			template<typename _Tbase, typename _Ty>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query_when_last_error_call(_Tbase* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, _Ty*)
			{
				return __do_query_when_last_error(static_cast<typename _Tbase::base_type*>(ptr), out_ptr, in_id);
			}
			template<typename _Tbase>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query_when_last_error(_Tbase* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, decltype(ptr->__self_query_itf_end) = 0)
			{
				return __do_query_when_last_error_call(ptr, out_ptr, in_id, (typename __get_mem_proc_owner<decltype(&_Tbase::__self_query_itf_end)>::owner_type*)0);
			}
			template<typename _Tbase>
			static LOLIX_INLINE_CALL LOLIX_RETNV do_query(itf* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id)
			{
				return __do_query_when_last_error(__do_cast_from<_Tbase*>(ptr), out_ptr, in_id, 0);
			}
			template<typename _Tbase>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query_when_last_error(_Tbase* /*ptr*/, itf** /*out_ptr*/, const LOLIX_ITF_ID* /*in_id*/, ...)
			{
				return LOLIX_ERROR_INVALID_TYPE;
			}
#else	//	LOLIX_CFG__SUPPORT_CPP_0X
			template<typename _Tbase>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query_when_last_error(_Tbase* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, __get_mem_proc_owner<_Tbase, &_Tbase::__self_query_itf_end>* = 0)
			{
				LOLIX_RETNV rtv;
				if ( !LOLIX_IS_ERROR(rtv = __do_query_when_last_error(static_cast<_Tbase::base_type*>(ptr), out_ptr, in_id)) )
					return rtv;
				return ptr->__self_query_itf_end(out_ptr, in_id);
			}
			template<typename _Tbase>
			static LOLIX_INLINE_CALL LOLIX_RETNV __do_query_when_last_error(_Tbase* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id, ...)
			{
				return __do_query_when_last_error(static_cast<_Tbase::base_type*>(ptr), out_ptr, in_id);
			}
			template<typename _Tbase>
			static LOLIX_INLINE_CALL LOLIX_RETNV do_query(itf* ptr, itf** out_ptr, const LOLIX_ITF_ID* in_id)
			{
				return __do_query_when_last_error_call(static_cast<_Tbase*>(ptr), out_ptr, in_id);
			}
#endif	//	LOLIX_CFG__SUPPORT_CPP_0X


#if			LOLIX_CFG__SUPPORT_CPP_0X
			template<typename _Ty>
			static LOLIX_INLINE_CALL size_type __do_inc_ref(_Ty const* ptr, decltype(ptr->__self_inc_ref) = 0)
			{
				return ptr->__self_inc_ref();
			}
			template<typename _Ty, typename _TAlc>
			static LOLIX_INLINE_CALL size_type __do_release(_Ty const* ptr, _TAlc /*alc*/, decltype(ptr->__self_release) = 0)
			{
				return ptr->__self_release();
			}
#else	//	LOLIX_CFG__SUPPORT_CPP_0X
	#if			LOLIX_CFG__PLATFORM_WINDOWS && LOLIX_CFG__SIZE_TYPE_BITS_SIZE < 64
			template<typename _Tm, size_type(__thiscall _Tm::*)(void)const> _have_thiscall_const_inc_release;
			template<typename _Tm, size_type(__stdcall _Tm::*)(void)const> _have_std_const_inc_release;
			template<typename _Tm, size_type(__cdecl _Tm::*)(void)const> _have_cdecl_const_inc_release;
			template<typename _Ty> static LOLIX_INLINE_CALL size_type __do_inc_ref(_Ty const* ptr, _have_thiscall_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_inc_ref();}
			template<typename _Ty, typename _TAlc>static LOLIX_INLINE_CALL size_type __do_release(_Ty const* ptr, _TAlc /*alc*/, _have_thiscall_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_release();}
			template<typename _Ty> static LOLIX_INLINE_CALL size_type __do_inc_ref(_Ty const* ptr, _have_std_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_inc_ref();}
			template<typename _Ty, typename _TAlc>static LOLIX_INLINE_CALL size_type __do_release(_Ty const* ptr, _TAlc /*alc*/, _have_std_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_release();}
			template<typename _Ty> static LOLIX_INLINE_CALL size_type __do_inc_ref(_Ty const* ptr, _have_cdecl_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_inc_ref();}
			template<typename _Ty, typename _TAlc>static LOLIX_INLINE_CALL size_type __do_release(_Ty const* ptr, _TAlc /*alc*/, _have_cdecl_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_release();}
		#if			!defined(_M_CEE)
			template<typename _Tm, size_type(__fastcall _Tm::*)(void)const> _have_fast_const_inc_release;
			template<typename _Ty> static LOLIX_INLINE_CALL size_type __do_inc_ref(_Ty const* ptr, _have_fast_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_inc_ref();}
			template<typename _Ty, typename _TAlc>static LOLIX_INLINE_CALL size_type __do_release(_Ty const* ptr, _TAlc /*alc*/, _have_fast_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_release();}
		#endif	//	!defined(_M_CEE)
	#else	//	LOLIX_CFG__PLATFORM_WINDOWS && LOLIX_CFG__SIZE_TYPE_BITS_SIZE < 64
			template<typename _Tm, size_type(_Tm::*)(void)const> _have_const_inc_release;
			template<typename _Ty> static LOLIX_INLINE_CALL size_type __do_inc_ref(_Ty const* ptr, _have_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_inc_ref();}
			template<typename _Ty, typename _TAlc>static LOLIX_INLINE_CALL size_type __do_release(_Ty const* ptr, _TAlc /*alc*/, _have_const_inc_release<_Ty, &_Ty::__self_inc_ref>* = 0){return ptr->__self_release();}
	#endif	//	LOLIX_CFG__PLATFORM_WINDOWS && LOLIX_CFG__SIZE_TYPE_BITS_SIZE < 64
#endif	//	LOLIX_CFG__SUPPORT_CPP_0X

			template<typename _Ty>
			static LOLIX_INLINE_CALL size_type __do_inc_ref(_Ty const* ptr, ...)
			{
				return ptr->_ref->inc_ref();
			}


			template<typename _Ty, typename _TAlc>
			static LOLIX_INLINE_CALL size_type __do_release(_Ty const* ptr, _TAlc alc, ...)
			{
				size_type ref = ptr->_ref->release();
				if ( ref )
					return ref;
				ptr->__lolix_inner_delete_this(alc);
				return 0;
			}

			template<typename _Ty>
			static LOLIX_INLINE_CALL size_type do_inc_ref(_Ty const* ptr)
			{
				return __do_inc_ref(ptr, 0);
			}

			template<typename _Ty, typename _TAlc>
			static LOLIX_INLINE_CALL size_type do_release(_Ty const* ptr, _TAlc alc)
			{
				return __do_release(ptr, alc, 0);
			}
		};
	}


	///	继承原点.
	///	\warning 关于工厂的说明: 凡是通过工厂中 create 出来的对象必须是已经被内部设置为标准引用
	///		因此外部可以直接 release, 而不需要额外的 inc_ref 过程调用
	///		希望所有工厂的建立者遵守这个基本约定
	class LOLIX_NO_VTABLE itf
	{
	public:
		LOLIX_DECLARE_ITF(itf, void, (0xF931B317, 0xC80946f6, 0xBD59E46A, 0x58FE1120));
		typedef	lolix::size_type		size_type;		///< \brief 无符号数量类型
		typedef	lolix::difference_type	difference_type;///< \brief 有符号差距类型
		typedef	lolix::ptrdiff_type		ptrdiff_type;	///< \brief 有符号差距类型
		typedef	lolix::LOLIX_RETNV		LOLIX_RETNV;	///< \brief 一般性错误类型
		typedef	lolix::LOLIX_ITF_ID		LOLIX_ITF_ID;	///< \brief 接口ID

		/**
		* \brief	增加引用计数
		*
		* \return 增加引用计数之后存在多少引用（仅供参考）
		**/
		LOLIX_INTERFACE(inc_ref		, size_type		, (void)const);

		/**
		* \brief	减少引用计数
		*
		* \return	减少引用计数之后存在多少引用（仅供参考）,
		*			为0则表示一定销毁了，非0不一定存在.
		*
		* \warning	不管是不是被释放了, 一旦 release 之后则不应该继续使用这个对象
		*			不要以为 release 之后立即 inc_ref 可以抢救回来这个对象哟( ^_^ )
		**/
		LOLIX_INTERFACE(release		, size_type		, (void)const);

		/**
		* \brief	得到当前对象的类型id
		*
		* \arg out	out_id	需要返回的对象的填充地址，外部给定
		**/
		LOLIX_INTERFACE(itf_id		, void			, (LOLIX_ITF_ID* out_id)const);

		/**
		* \brief	尝试转换类型
		*
		* \arg out	out_itf 返回的新类型的对象：可能和当前对象不是一个对象，但存在等价关系
		* \arg		in_id	尝试获取的类型 id
		*
		* \return	成功返回 LOLIX_RETURN_OK, 失败 LOLIX_IS_ERROR(return) == true
		**/
		LOLIX_INTERFACE(query_itf	, LOLIX_RETNV	, (itf** out_itf, const LOLIX_ITF_ID* in_id));

		#pragma	region	//	query_itf 重载
		/**
		* \brief	自动尝试转换为输入类型的接口
		*
		* \arg out	out_ptr	转换后的接口
		*
		* \return	LOLIX_IS_ERROR 为false则成功，失败则为true
		**/
		template<typename _Ty>
		LOLIX_INLINE_CALL	LOLIX_RETNV	query_itf(_Ty const& out_ptr)
			{
			const LOLIX_ITF_ID id(LOLIX_ITF_FROM_TYPE(_Ty));
			return query_itf((itf**)out_ptr, &id);
			}

		/**
		* \brief	自动尝试转换为输入类型的接口
		*
		* \arg out	out_ptr	转换后的接口
		*
		* \return	LOLIX_IS_ERROR 为false则成功，失败则为true
		**/
		template<typename _Ty>
		LOLIX_INLINE_CALL	LOLIX_RETNV	query_itf(void* out_ptr)
			{
			const LOLIX_ITF_ID itfid(LOLIX_ITF_FROM_TYPE(_Ty));
			return query_itf((itf**)out_ptr, &itfid);
			}

		/**
		* \brief	自动尝试转换为输入类型的接口
		*
		* \arg out	out_ptr	转换后的接口
		*
		* \return	LOLIX_IS_ERROR 为false则成功，失败则为true
		**/
		template<typename _Ty>
		LOLIX_INLINE_CALL	LOLIX_RETNV	query_itf(_Ty const** out_ptr)const
			{
			const LOLIX_ITF_ID itfid(LOLIX_ITF_FROM_TYPE(_Ty));
			return const_cast<this_type*>(this)->query_itf((itf**)out_ptr, &itfid);
			}

		/**
		* \brief	自动尝试转换为输入类型的接口
		*
		* \arg out	out_ptr	转换后的接口
		*
		* \return	LOLIX_IS_ERROR 为false则成功，失败则为true
		**/
		template<typename _Ty>
		LOLIX_INLINE_CALL	LOLIX_RETNV	query_itf(_Ty** out_ptr)
			{
			const LOLIX_ITF_ID itfid(LOLIX_ITF_FROM_TYPE(_Ty));
			return this->query_itf((itf**)out_ptr, &itfid);
			}

		#pragma	endregion
		#pragma	region	//	增加和减少应用的自动对象
		///	减少一个对象的引用
		///	tparam not_check_null true)不会检查是否对象为空; false)检查当前对象是否为空
		template<bool not_check_null>
		class	dec_itf
		{
		public:
			LOLIX_INLINE_CALL	void	operator()(itf* i)const
			{
				if ( not_check_null || i )
					i->release();
			}
		};
		template<bool not_check_null>
		class	inc_itf
		{
		public:
			LOLIX_INLINE_CALL	void	operator()(itf* i)const
			{
				if ( not_check_null || i )
					i->inc_ref();
			}
		};
		#pragma endregion
		#pragma region	//	判断后增加和释放
		/**
		* \brief	安全的增加引用
		* \return	返回调用此函数之后的引用值
		* \remark	如果在空指针上调用，则返回0
		**/
		LOLIX_INLINE_CALL size_type safe_inc_ref(void)const{ if ( this ) return this->inc_ref(); return 0; }
		/**
		* \brief	安全的减少引用
		* \return	返回此调用之后的引用值
		* \remark	如果返回为0，则表示正确释放了，或者所调用的对象本身就是空指针
		**/
		LOLIX_INLINE_CALL size_type safe_release(void)const{ if ( this ) this->release(); return 0;}
		#pragma endregion
	};


#define		LOLIX_DEFINE_FACTORY(__LX_FC_ID, __LX_FC_PARAM)				\
	class	LOLIX_NO_VTABLE	factory_type	: public ::lolix::itf		\
	{																	\
	public:																\
		LOLIX_DECLARE_ITF(factory_type, itf, __LX_FC_ID);				\
		LOLIX_INTERFACE(create_inst	, LOLIX_RETNV	, __LX_FC_PARAM);	\
	}

#define		LOLIX_DECLARE_PROXY(__LX_FC_ID_R, __LX_FC_ID_G, __LX_FC_ID_B, __LX_FC_ID_A)		__LOLIX_DECLARE_PROXY_WITH_NAME(LOLIX_DEF__LINK_SYMBOL(__PROXY_BASE_TYPE, __COUNT__),(__LX_FC_ID_R, __LX_FC_ID_G, __LX_FC_ID_B, __LX_FC_ID_A))
#define		__LOLIX_DECLARE_PROXY_WITH_NAME(__LX_PROXY_TYPE, __LX_FC_ID)\
	typedef this_type	__LX_PROXY_TYPE;								\
	class	LOLIX_NO_VTABLE proxy_type		: public ::lolix::itf		\
	{																	\
	public:																\
		typedef	__LX_PROXY_TYPE	proxied_type;							\
		LOLIX_DECLARE_ITF(proxy_type, itf, __LX_FC_ID);					\
		LOLIX_INTERFACE(query		, LOLIX_RETNV	, (const proxied_type** out_ptr)const);\
		LOLIX_INTERFACE(query		, LOLIX_RETNV	, (proxied_type** out_ptr));			\
	}

	/**
	* \class	动态内存分配
	*
	* \remark	需要支持以下两个类型请求 loli_clone, loli_copy
	**/
	class	LOLIX_NO_VTABLE	dynamic_allocator
		: public lolix::itf
	{
	public:
		LOLIX_DECLARE_ITF(lolix::dynamic_allocator, lolix::itf, (0xc7e1e35e, 0x7c554e09, 0xa0952b58, 0x8ab4ffe9));
		LOLIX_DEFINE_FACTORY((0xc255601e, 0xd4fbf751, 0x996d4dba, 0x907eb9ab), (dynamic_allocator**));
		/**
		* \brief	分配匿名内存
		* \arg out	out_buffer 返回的实际内存地址
		* \arg mem_block_size 请求的内存的字节数
		* \return
		*		# LOLIX_RETNV_OK			没有问题
		*		# LOLIX_ERROR_LESS_MEMORY	内存不足
		**/
		LOLIX_INTERFACE(allocate	, LOLIX_RETNV	, (void** out_buffer, size_type mem_block_size));

		/**
		* \brief				释放内存
		* \arg mem				使用该类所得到的内存	\see allocate
		* \arg mem_block_size	该内存块的大小
		* \return
		*		# LOLIX_RETNV_OK	没有问题
		* \warning mem_block_size 大小必须正确
		**/
		LOLIX_INTERFACE(deallocate	, LOLIX_RETNV	, (void* mem, size_type mem_block_size));

		/**
		* \brief 分配内存
		* \arg 	buffer			[out]	返回的实际内存地址
		* \arg	mem_block_size	[in]	请求的内存的字节数
		* \arg	name			[in]	该内存块的名字, 必须正确
		* \return
		*		# LOLIX_RETNV_OK					没有问题
		*		# LOLIX_ERROR_LESS_MEMORY			内存不足
		*		# LOLIX_WARNING_UNSUPPORT_INTERFACE	接口不被支持(将返回实际的地址， 如同不带名字的 allocate 接口)
		*		[如果使用的是 LoliX 内部版本， 则有可能该编译版本没有指定 LOLIX_CFG__OPEN_MEM_ALLOC_TRACE ]
		*			\see	lolix_cfg.h
		**/
		LOLIX_INTERFACE(allocate	, LOLIX_RETNV	, (void** buffer, size_type mem_block_size, const char* name));

		/**
		* \brief	释放内存
		* \arg	mem				使用该类所得到的内存 \see allocate
		* \arg	mem_block_size	该内存块的大小 : 必须正确
		* \arg	name			该内存的名字	: 开启名称检测的版本必须指定正确名字
		* \return
		*		# LOLIX_RETNV_OK			没有问题
		*		# LOLIX_WARNING_UNSUPPORT_INTERFACE		接口不被支持(将删除实际的地址， 如同没有名字跟踪)
		*				[如果使用的是 LoliX 内部版本， 则有可能该编译版本没有指定 LOLIX_CFG__OPEN_MEM_ALLOC_TRACE ]
		*				\see lolix_cfg.h
		**/
		LOLIX_INTERFACE(deallocate	, LOLIX_RETNV	, (void* mem, size_type mem_block_size, const char* name));
	};


	///	\brief	线程安全指定标记
	enum ENUM_THREAD_SAFE
	{
		THREAD_SAFE_SRW		,	///< 单线程读写安全				key_bind
		THREAD_SAFE_SRSW	,	///< 单线程读-单线程写安全		swap_list
		THREAD_SAFE_SRMW	,	///< 单线程读-多线程写安全
		THREAD_SAFE_MRSW	,	///< 多线程读-单线程写安全
		THREAD_SAFE_MRW		,	///< 多线程读写安全
	};


	/**
	* \brief	常用的引用计数接口，来作为第三方需要引用计数的对象使用
	**/
	class LOLIX_NO_VTABLE ref_counter
		: public lolix::itf
	{
	public:
		LOLIX_DEFINE_FACTORY((0xe10fc028, 0xf411e9c0, 0x99ab909a, 0x3b6a9464), (ref_counter**, ENUM_THREAD_SAFE));
		LOLIX_DECLARE_ITF(ref_counter, lolix::itf, (0x291D7AC2, 0x2B4F405e, 0xB49B31A4, 0x0B013013));
		/**
		* \brief	得到当前引用数
		* \return	当前的引用数
		**/
		LOLIX_INTERFACE(size	, size_type	, (void)const);
	};

	typedef	ref_counter::factory_type	ref_factory;

	////////////////////////////////////////////////////////////////////////////
	///\brief	日志
	////////////////////////////////////////////////////////////////////////////
	//	QUERY_ITF:	factory_type
	////////////////////////////////////////////////////////////////////////////
	class	LOLIX_NO_VTABLE	diary
		: public itf
	{
		typedef	const wchar_t*	_fmt_type;
	public:
		LOLIX_DEFINE_FACTORY((0x77156ba2, 0x3477d4f0, 0x838ca82a, 0xbd9901a5), (diary** out_ptr, wchar_t* title));
		LOLIX_DECLARE_ITF(diary, itf, (0x8e85199f, 0xb4e15acc, 0xebb993eb, 0x6aec8faf));
		LOLIX_INTERFACE(title,	_fmt_type,		(void)const);
		LOLIX_INTERFACE(write,	LOLIX_RETNV,	(_fmt_type* data));
	};


#define		LOLIX_DEFINE_ID_INTERFACE(this_type, id)	LOLIX_DEFINE_ID_INTERFACE_FROM_SPECIFIC_TYPE(this_type, ::lolix::itf, id)
#define		LOLIX_DEFINE_ID_INTERFACE_FROM_SPECIFIC_TYPE(this_type, base_type, id)	class	LOLIX_NO_VTABLE	this_type: public base_type{ public: LOLIX_DECLARE_ITF(this_type, base_type, id); }
	//	!!	下面两个功能接口的返回值是 顶层基类的意义是可以通过传递这个指针来保存原始的含义
	//	!!	不至于丢失原本类型信息
	//	!!	但是实现接口的时候， 需要保证当使用者直接传递参数后，可以通过强转指针获得正确的类型
	//	clone : 创建一个同类型的对象的初始默认形态， 功能上一致， 同时不保证内部数据一致
	LOLIX_DEFINE_ID_INTERFACE(loli_clone	,	(0x74fe3809, 0xe92a47d5, 0x910d8115, 0x32060dff));
	//	copy : 创建一个同类型的对象的当前形态， 功能上一致， 同时确保内部数据一致
	LOLIX_DEFINE_ID_INTERFACE(loli_copy	,	(0xfef3c216, 0x15c54800, 0x8b36bac0, 0x226a01fd));

	//	loli_fmt:
	//	TOKEN = $STR_FMT$
	//	STR_FMT	= USINGED:TYPE	//-	(ADDITION_FLAG)
	//-	ADDITION_FLAG = <{0...9, a...z, A...z}>(ADDITION_FLAG)
	//	TYPE	= (SIGNED)(.USINGED).TYPE_FLAG(USINGED)
	//	TYPE_FLAG = u | d | i | s | c | f | F | m | itf | x | X | o
	//	USIGNED	= (+)	USIGNED_NUM
	//	SIGNED	= (+|-) USIGNED_NUM
	//	USIGNED_NUM	= {0...9} | 0x{0..9, a...f} | 0{0...7}
	//	---------------------------------------------------
	//	ex. "$$" -> "$"
	//		"$1:.u16$"
	//		"$3:0x08.30.itf3$"
	//-		"$0:-13.+64.u+32<color:0xff000000><size:23pt><new_line:center, new_line:right>$"
	LOLIX_DEFINE_ID_INTERFACE(prink_loli_fmt, (0x061fc620, 0x041396c3, 0x42e03788, 0x37a94cb5));

	class	LOLIX_NO_VTABLE	swap_loli
		: public itf
	{
	public:
		LOLIX_DECLARE_ITF(swap_loli, itf, (0x6db0902a, 0x7042462d, 0x8b0d0216, 0x920bd07b));
		LOLIX_INTERFACE(swap	, LOLIX_RETNV	, (itf* o));
	};


	namespace _help
	{
#if			LOLIX_CFG__USE_LOCK_OPT_REF_COUNTER
		template<typename _TySize, bool>
		class _TRefHandle
		{
			_TySize	_ref;
			LOLIX_INLINE_CALL _TRefHandle(_TySize ref):_ref(ref){}
		public:
			LOLIX_INLINE_CALL _TRefHandle(void){}
			static LOLIX_INLINE_CALL  LOLIX_RETNV create_inst(_TRefHandle* out_ptr, lolix::ref_factory* /*ref_fac*/){out_ptr->_ref = 1;return LOLIX_RETNV_OK;}
			static LOLIX_INLINE_CALL  LOLIX_RETNV create_inst(_TRefHandle* out_ptr){out_ptr->_ref = 1;return LOLIX_RETNV_OK;}
			LOLIX_INLINE_CALL size_type inc_ref(void)const{return imp::lock_inc(&_ref);}
			LOLIX_INLINE_CALL size_type release(void)const{return imp::lock_dec(&_ref);}
			LOLIX_INLINE_CALL size_type size(void)const{return _ref;}
			LOLIX_INLINE_CALL _TRefHandle* operator->(void){return this;}
			LOLIX_INLINE_CALL _TRefHandle const* operator->(void)const{return this;}
		};

		template<typename _TySize>
		class _TRefHandle<_TySize, false>
		{
			lolix::ref_counter* _ref;
		public:
			LOLIX_INLINE_CALL _TRefHandle(void){}
			LOLIX_INLINE_CALL explicit _TRefHandle(lolix::ref_counter* ref)
				: _ref(ref){}
			static LOLIX_INLINE_CALL lolix::LOLIX_RETNV create_inst(_TRefHandle* out_ptr, lolix::ref_factory* ref_fac)
			{
				return ref_fac->create_inst(&out_ptr->_ref, lolix::THREAD_SAFE_MRW);
			}
			LOLIX_INLINE_CALL size_type inc_ref(void)const{return _ref->inc_ref();}
			LOLIX_INLINE_CALL size_type release(void)const{return _ref->release();}
			LOLIX_INLINE_CALL size_type size(void)const{return _ref->size();}
			LOLIX_INLINE_CALL _TRefHandle* operator->(void){return this;}
			LOLIX_INLINE_CALL _TRefHandle const* operator->(void)const{return this;}
			LOLIX_INLINE_CALL _TRefHandle& operator = (lolix::ref_counter* ref){_ref = ref;return *this;}
		};

		template<typename _Trefhandle>
		LOLIX_INLINE_CALL LOLIX_RETNV query_ref_handle(_Trefhandle* ref, ref_factory* ref_fac)
		{
			return _Trefhandle::create_inst(ref, ref_fac);
		}
		template<typename _Trefhandle>
		LOLIX_INLINE_CALL LOLIX_RETNV query_ref_handle(_Trefhandle* ref)
		{
			return _Trefhandle::create_inst(ref);
		}
#endif	//	LOLIX_CFG__USE_LOCK_OPT_REF_COUNTER
		LOLIX_INLINE_CALL LOLIX_RETNV query_ref_handle(ref_counter** ref, ref_factory* ref_fac)
		{
			return ref_fac->create_inst(ref, THREAD_SAFE_MRW);
		}
	}

	namespace toy
	{
		template<typename _Ty, bool _Vnonull, typename _RefProxy>
		class	loli_ptr;
	}
	/**
	* \brief	作为 itf 的中间层，用来辅助创建过程
	* \tparam	_Tthis	当前对象的类型
	* \tparam	_Tbase	基类对象的类型
	**/
	template<typename _Tthis, typename _Tbase>
	class LOLIX_NO_VTABLE itf_Tbase
		: public _Tbase
	{
	protected:
		typedef itf_Tbase						_Tbase_type;
		LOLIX_INLINE_CALL static void __assign_alc__(dynamic_allocator*& al, dynamic_allocator* ar){(al = ar)->inc_ref();}
		template<typename _Tx>
		LOLIX_INLINE_CALL static void __assign_alc__(_Tx& al, dynamic_allocator* ar){al = ar;}
	public:
		/**
		* \brief	默认构造函数
		**/
		LOLIX_INLINE_CALL itf_Tbase(void)
			: _Tbase()
		{}
		#pragma region	快速宏定义展开
#if			defined(_TT_)
	#define		__LOLIX_TMP__NEED_DEF__TT__
	#pragma	push_macro(_TT_)
	#undef	_TT_
#endif	//	defined(_TT_)
#if			defined(_DT_)
	#define		__LOLIX_TMP__NEED_DEF__DT__
	#pragma	push_macro(_DT_)
	#undef	_DT_
#endif	//	defined(_TT_)
#if			defined(_PT_)
	#define		__LOLIX_TMP__NEED_DEF__PT__
	#pragma	push_macro(_PT_)
	#undef	_PT_
#endif	//	defined(_PT_)

#if			LOLIX_CFG__SUPPORT_CPP_0X
	#define		_TT_(n)	typename _T##n
	#define		_DT_(n) _T##n&& t##n
	#define		_PT_(n) forward<_T##n>(t##n)
#else	//	LOLIX_CFG__SUPPORT_CPP_0X
	#define		_TT_(n)	typename _T##n
	#define		_DT_(n) const _T##n& t##n
	#define		_PT_(n) t##n
#endif	//	LOLIX_CFG__SUPPORT_CPP_0X

#define	__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC	\
	LOLIX_RETNV rtv;\
	typename _Tthis::ref_type ref;\
	if ( LOLIX_CHECK_ERROR(rtv = _help::query_ref_handle(&ref, ref_fac)) )\
		return rtv;\
	typename _Tthis::allocator_type	alc_this(alc);\
	_Tthis* ptr = alc_this.allocate(1);\
	if ( !ptr )\
	{\
		ref->release();\
		return LOLIX_ERROR_LESS_MEMORY;\
	}alc_this.construct

#define	__LOLIX_TMP__BEGIN__CREATE_INST	\
	LOLIX_RETNV rtv;\
	typename _Tthis::ref_type ref;\
	if ( LOLIX_CHECK_ERROR(rtv = _help::query_ref_handle(&ref)) )\
		return rtv;\
	typename _Tthis::allocator_type	alc_this(alc);\
	_Tthis* ptr = alc_this.allocate(1);\
	if ( !ptr )\
	{\
		ref->release();\
		return LOLIX_ERROR_LESS_MEMORY;\
	}alc_this.construct

#define	__LOLIX_TMP__END__CREATE_INSET_SET_ALC()	\
	ptr->_ref = ref;\
	__assign_alc__(ptr->_alc, alc);\
	*out_ptr = ptr;\
	return LOLIX_RETNV_OK

#define	__LOLIX_TMP__END__CREATE_INSET()	\
	ptr->_ref = ref;\
	*out_ptr = ptr;\
	return LOLIX_RETNV_OK

		#pragma endregion
		template<_TT_(0)>
		LOLIX_INLINE_CALL itf_Tbase(_DT_(0)): _Tbase(_PT_(0)){}
		template<_TT_(0), _TT_(1)>
		LOLIX_INLINE_CALL itf_Tbase(_DT_(0), _DT_(1)): _Tbase(_PT_(0), _PT_(1)){}

		template<typename _Tout>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc)
		{
			__LOLIX_TMP__BEGIN__CREATE_INST(ptr);
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac)
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr);
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, _DT_(0))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST(ptr, _PT_(0));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac, _DT_(0))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0), bool _Vnonnull, typename _RefProxy>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, toy::loli_ptr<lolix::ref_factory, _Vnonnull, _RefProxy>& ref_fac, _DT_(0))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0), _TT_(1)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, _DT_(0), _DT_(1))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST(ptr, _PT_(0), _PT_(1));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0), _TT_(1)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac, _DT_(0), _DT_(1))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0), _PT_(1));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0), _TT_(1), bool _Vnonnull, typename _RefProxy>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, toy::loli_ptr<lolix::ref_factory, _Vnonnull, _RefProxy>& ref_fac, _DT_(0), _DT_(1))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0), _PT_(1));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0), _TT_(1), _TT_(2)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, _DT_(0), _DT_(1), _DT_(2))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST(ptr, _PT_(0), _PT_(1), _PT_(2));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0), _TT_(1), _TT_(2)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac, _DT_(0), _DT_(1), _DT_(2))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0), _PT_(1), _PT_(2));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout, _TT_(0), _TT_(1), _TT_(2), _TT_(3)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst_set_alc(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac, _DT_(0), _DT_(1), _DT_(2), _DT_(3))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0), _PT_(1), _PT_(2), _PT_(3));
			__LOLIX_TMP__END__CREATE_INSET_SET_ALC();
		}

		template<typename _Tout>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst(_Tout** out_ptr, lolix::dynamic_allocator* alc)
		{
			__LOLIX_TMP__BEGIN__CREATE_INST(ptr);
			__LOLIX_TMP__END__CREATE_INSET();
		}

		template<typename _Tout>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac)
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr);
			__LOLIX_TMP__END__CREATE_INSET();
		}

		template<typename _Tout, _TT_(0)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac, _DT_(0))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0));
			__LOLIX_TMP__END__CREATE_INSET();
		}


		template<typename _Tout, _TT_(0)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst(_Tout** out_ptr, lolix::dynamic_allocator* alc, _DT_(0))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST(ptr, _PT_(0));
			__LOLIX_TMP__END__CREATE_INSET();
		}

		template<typename _Tout, _TT_(0), _TT_(1)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac, _DT_(0), _DT_(1))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0), _PT_(1));
			__LOLIX_TMP__END__CREATE_INSET();
		}

		template<typename _Tout, _TT_(0), _TT_(1), _TT_(2)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac, _DT_(0), _DT_(1), _DT_(2))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0), _PT_(1), _PT_(2));
			__LOLIX_TMP__END__CREATE_INSET();
		}

		template<typename _Tout, _TT_(0), _TT_(1), _TT_(2), _TT_(3)>
		static LOLIX_INLINE_CALL	LOLIX_RETNV	__Create_inst(_Tout** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_counter::factory_type* ref_fac, _DT_(0), _DT_(1), _DT_(2), _DT_(3))
		{
			__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC(ptr, _PT_(0), _PT_(1), _PT_(2), _PT_(3));
			__LOLIX_TMP__END__CREATE_INSET();
		}
		#pragma region	快速宏定义还原

#undef	__LOLIX_TMP__END__CREATE_INSET
#undef	__LOLIX_TMP__END__CREATE_INSET_SET_ALC
#undef	__LOLIX_TMP__BEGIN__CREATE_INST
#undef	__LOLIX_TMP__BEGIN__CREATE_INST_WITH_REF_FAC

#if			defined(__LOLIX_TMP__NEED_DEF__TT__)
	#pragma	pop_macro(_TT_)
	#undef	__LOLIX_TMP__NEED_DEF__TT__
#endif	//	defined(__LOLIX_TMP__NEED_DEF__TT__)
#if			defined(__LOLIX_TMP__NEED_DEF__DT__)
	#pragma	pop_macro(_DT_)
	#undef	__LOLIX_TMP__NEED_DEF__DT__
#endif	//	defined(__LOLIX_TMP__NEED_DEF__DT__)
#if			defined(__LOLIX_TMP__NEED_DEF__PT__)
	#pragma	pop_macro(_PT_)
	#undef	__LOLIX_TMP__NEED_DEF__PT__
#endif	//	defined(__LOLIX_TMP__NEED_DEF__PT__)
		#pragma endregion
	};

	namespace type{
		/**
		* \brief	类型的最大最小信息
		* \tparam	type_name	类型信息
		**/
		template<typename type_name>
		class type_value;

		///	\brief	lx_i8	类型的最大最小值定义
		template<>		class type_value<lx_i8>		{public:enum {/**\brief 最大值**/max_val=	0x0000007f, /**\brief 最小值**/min_val=	0x00000080};};
		///	\brief	lx_i16	类型的最大最小值定义
		template<>		class type_value<lx_i16>	{public:enum {/**\brief 最大值**/max_val=	0x00007fff, /**\brief 最小值**/min_val=	0x00008000};};
		///	\brief	lx_i32	类型的最大最小值定义
		template<>		class type_value<lx_i32>	{public:enum {/**\brief 最大值**/max_val=	0x7fffffff, /**\brief 最小值**/min_val=	0x80000000};};
#if			LOLIX_CFG__SUPPORT_CPP_0X
		__PUSH_AND_DISABLE_WARNING(4480)
		///	\brief	lx_i64	类型的最大最小值定义
		template<>		class type_value<lx_i64>	{public:enum:lx_i64{/**\brief 最大值**/max_val=0x7fffffffffffffff,	/**\brief 最小值**/min_val=(lx_i64)0x8000000000000000};};
		__POP_WARNING()
#else	//	LOLIX_CFG__SUPPORT_CPP_0X
		///	\brief	lx_i64	类型的最大最小值定义
		template<>		class type_value<lx_i64>	{public:/**\brief 最大值**/static const lx_i64	max_val=	0x7fffffffffffffff,	/**\brief 最小值**/min_val=	0x8000000000000000;};
#endif	//	LOLIX_CFG__SUPPORT_CPP_0X

		///	\brief	lx_u8	类型的最大最小值定义
		template<>		class type_value<lx_u8>		{public:enum {/**\brief 最大值**/max_val=	0x000000ff, /**\brief 最小值**/min_val=	0x00000000};};
		///	\brief	lx_u16	类型的最大最小值定义
		template<>		class type_value<lx_u16>	{public:enum {/**\brief 最大值**/max_val=	0x0000ffff, /**\brief 最小值**/min_val=	0x00000000};};
		///	\brief	lx_u32	类型的最大最小值定义
		template<>		class type_value<lx_u32>	{public:enum {/**\brief 最大值**/max_val=	0xffffffff, /**\brief 最小值**/min_val=	0x00000000};};
#if			LOLIX_CFG__SUPPORT_CPP_0X
		__PUSH_AND_DISABLE_WARNING(4480)
		///	\brief	lx_u64	类型的最大最小值定义
		template<>		class type_value<lx_u64>	{public:enum:lx_u64{/**\brief 最大值**/max_val=0xffffffffffffffff,	/**\brief 最小值**/min_val=0x0000000000000000};};
		__POP_WARNING()
#else	//	LOLIX_CFG__SUPPORT_CPP_0X
		///	\brief	lx_u64	类型的最大最小值定义
		template<>		class type_value<lx_u64>	{public:/**\brief 最大值**/static const lx_u64	max_val=	0xffffffffffffffff,	/**\brief 最小值**/min_val=	0x0000000000000000;};
#endif	//	LOLIX_CFG__SUPPORT_CPP_0X

		/**
		* \brief		是否是有符号对象
		**/
		template<typename>	class	is_signed;
		/**
		* \brief		判断是否是内部类型
		* \tparam	_Ty 待判断的类型
		**/
		template<typename _Ty> class is_inner_type{public: enum {/**\brief 是否是内部类型**/result_value = 0};/**\brief 是否是内部类型**/typedef type_false result_type;};
#define		__LOLIX__IS_SIGNED__TMP_PROC(iss, type)				template<>	class	is_signed<type>		{ public: typedef	iss	value_type; }; template<> class is_inner_type<type>{public:enum {result_value = 1};typedef type_true result_type;}
		__LOLIX__IS_SIGNED__TMP_PROC(type_false, unsigned char);
		__LOLIX__IS_SIGNED__TMP_PROC(type_false, unsigned short);
		__LOLIX__IS_SIGNED__TMP_PROC(type_false, unsigned int);
		__LOLIX__IS_SIGNED__TMP_PROC(type_false, unsigned long);
		__LOLIX__IS_SIGNED__TMP_PROC(type_false, unsigned long long);

		__LOLIX__IS_SIGNED__TMP_PROC(type_true, char);
		__LOLIX__IS_SIGNED__TMP_PROC(type_true, short);
		__LOLIX__IS_SIGNED__TMP_PROC(type_true, int);
		__LOLIX__IS_SIGNED__TMP_PROC(type_true, long);
		__LOLIX__IS_SIGNED__TMP_PROC(type_true, long long);
		__LOLIX__IS_SIGNED__TMP_PROC(type_true, float);
		__LOLIX__IS_SIGNED__TMP_PROC(type_true, double);
		__LOLIX__IS_SIGNED__TMP_PROC(type_true, long double);
#undef		__LOLIX__IS_SIGNED__TMP_PROC

#define	__LOLIX__SET_IS_INNER_TYPE__TMP_PROC(tp, type) template<typename tp> class is_inner_type<type>{public: enum{result_value = 1}; typedef type_true result_type;}
		__LOLIX__SET_IS_INNER_TYPE__TMP_PROC(_Ty, _Ty*);
		__LOLIX__SET_IS_INNER_TYPE__TMP_PROC(_Ty, const _Ty*);
		__LOLIX__SET_IS_INNER_TYPE__TMP_PROC(_Ty, _Ty&);
		__LOLIX__SET_IS_INNER_TYPE__TMP_PROC(_Ty, const _Ty&);
#undef	__LOLIX__SET_IS_INNER_TYPE__TMP_PROC

		/**
		* \brief	判断对象是否有析构函数
		* \tparam	_Ty	待判断对象
		**/
		template<typename _Ty> struct is_have_destructor{public: enum{/**\brief 是否存在析构函数值形式的结果**/result_value = is_inner_type<_Ty>::result_value?0:1};/**\brief 是否存在析构函数，类型形式的结果**/typedef typename type_choise<is_inner_type<_Ty>::result_value, type_false, type_true>::type result_type;};
	}

	class init_for_nothing_copy{};
	struct	byte_buffer
	{
		LOLIX_INLINE_CALL	byte_buffer(){}
		LOLIX_INLINE_CALL	byte_buffer(const init_for_nothing_copy){}
		lx_u8	val;
	};
	STATIC_ASSERT(sizeof(byte_buffer) == 1);

	namespace type{
		/**
		* \brief byte_buffer是否存在析构函数的特化
		**/
		template<> struct is_have_destructor<byte_buffer>{public: enum{/**\brief 没有携带析构函数 */result_value = 0}; /**\brief 没有携带析构函数*/typedef type_false result_type;};
	}


	enum ENUM_VALUE_TYPE
	{	VALUE_TYPE_VOID
	,	VALUE_TYPE_I8
	,	VALUE_TYPE_U8
	,	VALUE_TYPE_I16
	,	VALUE_TYPE_U16
	,	VALUE_TYPE_F16
	,	VALUE_TYPE_I32
	,	VALUE_TYPE_U32
	//	8
	,	VALUE_TYPE_F32
	,	VALUE_TYPE_I64
	,	VALUE_TYPE_U64
	,	VALUE_TYPE_F64
	//	0x0c
	,	_VALUE_TYPE_CNT
	,	_VALUE_TYPE_VER = 1
	};

	LOLIX_INLINE_CALL	size_type	get_value_type_size(ENUM_VALUE_TYPE etype)
	{
		const static size_type size[] =
		{	0
		,	1,	1
		,	2,	2
		,	4,	4
		,	8,	8
		,	2,	4,	8
		};

		return size[etype];

#if			defined(STATIC_ASSERT)
		STATIC_ASSERT(ARRAY_SIZE(size) == _VALUE_TYPE_CNT);
#endif	//	defined(STATIC_ASSERT)
	}

#define	__LOLIX_TMP_DEFINE__DEF_TYPE__(bits_cnt)	LOLIX_INLINE_CALL lx_u##bits_cnt abs(lx_u##bits_cnt v){return v;} LOLIX_INLINE_CALL lx_i##bits_cnt abs(lx_i##bits_cnt v){return v & type::type_value<lx_i##bits_cnt>::max_val;}
	__LOLIX_TMP_DEFINE__DEF_TYPE__(8);	//	lx_i8, lx_u8
	__LOLIX_TMP_DEFINE__DEF_TYPE__(16);	//	lx_i16, lx_u16
	__LOLIX_TMP_DEFINE__DEF_TYPE__(32);	//	lx_i32, lx_u32
	__LOLIX_TMP_DEFINE__DEF_TYPE__(64);	//	lx_i64, lx_u64
#undef	__LOLIX_TMP_DEFINE__DEF_TYPE__
	LOLIX_INLINE_CALL lx_f32 abs(lx_f32 v){(lx_u32&)v &= 0x7fffffff; return v;}
	LOLIX_INLINE_CALL lx_f64 abs(lx_f64 v){((lx_u32*)&v)[1] &= 0x7fffffff; return v;}

}


#if			!defined(__LOLIX__TOY_ALLOCATOR__K_IN_G__)
	#include	"./toy/allocator.h"
#endif	//	!defined(__LOLIX__TOY_ALLOCATOR__K_IN_G__)

//==============================================================================
#endif	//	!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
